// import Fly from 'flyio/dist/npm/fly'
import fly from 'flyio'
import Vue from 'vue'
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
// import adapter from 'flyio/dist/npm/adapter/dsbridge'
// import EngineWrapper from "flyio/dist/npm/engine-wrapper"
// let dsEngine = EngineWrapper(adapter);
// let fly = new Fly(dsEngine);
dayjs.locale("zh-cn")

// if(node)
if(process.env.NODE_ENV != "production"){
    fly.config.baseURL = "/api";
}else {
    fly.config.baseURL = "/";
}
fly.config.withCredentials = true;

//添加响应拦截器，响应拦截器会在then/catch处理之前执行
fly.interceptors.response.use(
    (response) => {
        //只将请求结果的data字段返回
        return response.data
    },
    (err) => {
        //发生网络错误后会走到这里
        console.error(err)
        //return Promise.resolve("ssss")
    }
);
Vue.filter('format',(value,format = 'YYYY.MM.DD')=>{
    return dayjs(value).format(format)
});
window.fly = fly;

export default fly;